package cc.bookcloud.tool.ocr.common.parsetext;

import com.alibaba.fastjson.JSONArray;
import cc.bookcloud.tool.ocr.util.ocr.OcrTextParseUtil;
import lombok.Data;

/**
 * @Desc: 火车票特征识别
 * @Version: 2.0
 * @Author: John Goo
 * @Date: 2024/11/29 11:37
 **/

@Data
public class InvoiceFeatureTrainTicket extends InvoiceFeatureAbstract {


    // 火车票编号
    private String ticketNoC = "{$}12804{$}0201";

    // 车次号
    private String trainNumberC = "02{车}03C{号}";

    // 标识A
    private String markA = "和谐号";

    // 标识B
    private String markB = "限乘当日当次车";


    public InvoiceFeatureTrainTicket(String type, String typeDesc){
        super(type,typeDesc);
    }

    public InvoiceFeatureTrainTicket() {

    }

    public boolean ticketNoC(Integer pos, String text, JSONArray array) {
        // 命中赋值 50
        Boolean isTrainNo = OcrTextParseUtil.isTrainTicketNo(pos, text);
        if (isTrainNo) {
            totalScore = totalScore + 50;
            return true;
        } else {
            return false;
        }
    }

    public boolean trainNumberC(Integer pos, String text,JSONArray array) {
        boolean isSeatNo = OcrTextParseUtil.isTrainSeatNo(text);
        if (isSeatNo && pos >= 6) {
            totalScore = totalScore + 50;
            return true;
        } else {
            return false;
        }


    }


    public boolean markA(Integer pos, String text,JSONArray array) {
        // 强标识,和谐号
        if (text.contains(this.markA)) {
            totalScore = totalScore + 100;
            return true;
        } else {
            return false;
        }
    }

    public boolean markB(Integer pos, String text,JSONArray array) {
        // 强标识,限乘当日当次车
        if (text.contains(markB)) {
            totalScore = totalScore + 50;
            return true;
        } else {
            return false;
        }
    }



}
